import Vue from "vue";
export default {
  state: {
    student: {
      name: "王小妹",
      sex: "M",
    },
    todos: [
      { id: 1, text: '...', done: true },
      { id: 2, text: '...', done: false }
    ]
  },

  getters: {
    student: state => state.student,
    doneTodos: state => {
      return state.todos.filter(todo => todo.done)
    }
  },

  mutations: {
    setAge(state) {
      Vue.set(state.student, 'age', 100)
    },
    addAge(state, num) {
      state.student.age += num;
    },
    add(state) {
      state.student.age++;
    },
    
  }
};
